package br.com.pontoclass.patterns;

import java.util.Scanner;

import br.com.pontoclass.primes.Base5PrimesListWriter;
import br.com.pontoclass.primes.DestinationList;
import br.com.pontoclass.primes.PrimesListWriter;


public class PrimesListWriterBuilder {
    
    private Scanner scanner;
    private DestinationList dl;

    private PrimesListWriterBuilder(Scanner scanner,
                                    DestinationList dl){
        this.scanner = scanner;
        this.dl = dl;
    }

    public static PrimesListWriterBuilder builder(Scanner scanner,
                                                  DestinationList dl) {
        return new PrimesListWriterBuilder(scanner, dl);
    }

    public PrimesListWriter build(Integer base) {
        if(base == 5) {
            return new Base5PrimesListWriter(scanner, dl);
        }
        throw new IllegalArgumentException(String.format("It was not found a PrimesListWriter corresponding to the base %d", base));
    }
}